#include <iostream>
#include "Object.h"
#include "Plant.h"
#include "Cabai.h"
#include "Mangga.h"
#include <vector>

using namespace std;

int main() {
	Object * obj = new Mangga;
	cout << obj->getObjectType() << endl;
	if(obj->getObjectType()==3) {//jika tanaman
		Plant* temp = dynamic_cast<Plant*>(obj);
		if(temp) {//jika dynamic_cast berhasil
			temp->harvested();
		}else{//kalo kgk
			cout << "typecasting tidak berhasil" << endl;
		}
	}
	obj = new Cabai;
	if(obj->getObjectType()==3) {
		Plant* temp = dynamic_cast<Plant*>(obj);
		if(temp) {//jika dynamic_cast berhasil
			temp->harvested();
		}else{
			cout << "typecasting tidak berhasil" << endl;
		}
	}
	//HATI2 OUT OF SCOPE arrobjek
	Object* arrobjek[2][2];
	arrobjek[0][0] = new Mangga;
	cout << arrobjek[0][0]->getObjectType() << endl;
	Plant* temp = dynamic_cast<Plant*>(arrobjek[0][0]);
	if(temp) {
		temp->harvested();
	}
	arrobjek[0][0] = new Cabai;
	temp = dynamic_cast<Plant*>(arrobjek[0][0]);
	if(temp) {
		temp->harvested();
	}
	//-----
	arrobjek[0][0] = new Cabai;
	arrobjek[0][1] = new Mangga;
	arrobjek[1][0] = new Mangga;
	arrobjek[1][1] = new Cabai;
	for(int i=0;i<2;i++) {
		for(int j=0;j<2;j++) {
			temp = dynamic_cast<Plant*>(arrobjek[i][j]);
			if(temp) {
				temp->harvested();
			}
		}
	}
	return 0;
}
